package cn.edu.controller;


import cn.edu.domain.All;
import cn.edu.domain.PageBean;
import cn.edu.domain.teacher;
import cn.edu.service.Col_ExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/Col_Examine")
public class Col_ExamineController  {

    @Autowired
    private Col_ExamineService examineService;
    /*审核通过*/
    @RequestMapping("/agree")
    public Result agree(Integer id) {
        boolean flag = examineService.agree(id);
        return new Result(flag?Code.UPDATE_ERR:Code.UPDATE_OK,"pass");
    }
    /*审核不通过*/
    @RequestMapping("/disagree")
    public Result disagree(Integer id) {
    //        调用Service的同意
        examineService.disagree(id);
    return new Result(Code.UPDATE_OK,"nopass");
    }
    /*查询未审核通过的页面*/
    @GetMapping("/{currentPage}/{pageSize}/{academyName}")
        public Result selectByPage(@PathVariable Integer currentPage,
                                 @PathVariable Integer pageSize,
                             @PathVariable String academyName
                            ){
        PageBean<All> pageBean = examineService.selectByPage(currentPage, pageSize,academyName);
        Integer code=pageBean!= null?Code.GET_OK:Code.GET_ERR;
        String msg=pageBean!=null?"查询成功":"数据查询失败，请重试";
        return new Result(code,pageBean,msg);
    }
/*查询已审核通过的页面*/
    @RequestMapping("/selectByPage2")
    public Result selectByPage2( Integer currentPage,
                                Integer pageSize,
                               String academyName){
        PageBean<teacher> pageBean = examineService.selectByPage2(currentPage, pageSize,academyName);
        Integer code=pageBean!= null?Code.GET_OK:Code.GET_ERR;
        String msg=pageBean!=null?"查询成功":"数据查询失败，请重试";
        return new Result(code,pageBean,msg);
    }
/* 取消审核*/
    @RequestMapping("/cancle")
    public Result cancle(Integer id) {

        examineService.cancle(id);
        return new Result(Code.UPDATE_ERR,"ok");
    }

}
